package com.gitee.wsl.mathematics.interpolator.ext

import com.gitee.wsl.mathematics.interpolator.PercentOrRatio
import com.gitee.wsl.mathematics.interpolator.Ratio
import com.gitee.wsl.mathematics.vector.vec2.Vector2D
import com.gitee.wsl.mathematics.vector.vec2.Vector2F

fun PercentOrRatio.interpolate(l: Float, r: Float): Float = (l + (r - l) * this.toFloat())
fun PercentOrRatio.interpolate(l: Double, r: Double): Double = (l + (r - l) * this.toDouble())
fun PercentOrRatio.interpolate(l: Ratio, r: Ratio) = (l + (r - l) * this)
fun PercentOrRatio.interpolate(l: Int, r: Int): Int = (l + (r - l) * this.toDouble()).toInt()
fun PercentOrRatio.interpolate(l: Long, r: Long): Long = (l + (r - l) * this.toDouble()).toLong()

fun PercentOrRatio.interpolate(l: Vector2F<*>, r: Vector2F<*>) = l.run {create(interpolate(l.x, r.x), interpolate(l.y, r.y)) }
fun PercentOrRatio.interpolate(l: Vector2D<*>, r: Vector2D<*>) = l.run {create(interpolate(l.x, r.x), interpolate(l.y, r.y)) }